<%--
  Created by IntelliJ IDEA.
  User: MGL
  Date: 2020/11/5
  Time: 9:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>授权菜单树</title>
    <link rel="stylesheet" type="text/css" href="../../css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/H-ui.admin.css" />
    <link rel="stylesheet" href="../../lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="../../lib/jquery/jquery-3.5.1.js"></script>
    <script type="text/javascript" src="../../lib/zTree/v3/js/jquery.ztree.all-3.5.js"></script>
    <script type="text/javascript" src="../../js/jquerySession.js"></script>
    <script type="text/javascript" src="../../js/H-ui.admin.js"></script>
    <script type="text/javascript" src="../../js/jsonFormat.js"></script>
    <SCRIPT LANGUAGE="JavaScript">
        var zTreeObj;
        // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）
        var setting = {
            callback: {
                onClick: zTreeOnClick
            },
            check: {
                enable: true,
                chkStyle: "checkbox",
                chkboxType: { "Y": "ps", "N": "ps" }
            }
        };

        // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
        var zNodes = [];


        $(document).ready(function(){

            var roleId="${roleId}"

            //1、根据角色Id查询菜单---简单JSon
            $.get("../getAuthorizationMenuListByRoleId/"+roleId,"",function (data) {
                var json=format(data)

                zNodes=json

                zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            });

        });

        function zTreeOnClick(event, treeId, treeNode) {
        };

        function selectDept(){
            // var menuName=$("#menuZtreeName").val()
            // var menuId=$("#menuZtreeId").val()
            //
            // if(!$("#menuZtreeName").val()){
            //     alert("请选择菜单")
            //     return;
            // }else {
            //     $.session.set("menuId",menuId)
            //     $.session.set("menuName",menuName)
            //
            //     layer_close()
            // }


        }
    </SCRIPT>
</head>
<body>
<div class="formControls col-xs-8 col-sm-9">
    <input id="menuZtreeName" type="text" style="width: 120px" class="input-text" name="menuZtreeName">
    <input id="menuZtreeId" type="hidden" >
    <input type="button" class="btn btn-primary radius" value="确定菜单" onclick="selectDept()">
    <ul id="treeDemo" class="ztree"></ul>
</div>
</body>
</html>
